<?php


namespace app;


use EasyWeChat\Factory;
use think\facade\Config;

/***  weChat 消息模板发送
 * Class WechatController
 * @package app
 */
class WechatController
{
    /*** 消息模板发送            订单即将失效
     * @param $openId           微信openID
     * @param array $data       模板数据格式
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public static function orderTimeOutWeChatMsgSend($openId,array $data){
        $config = [
            'app_id' => Config::get('app.wx_gzh_AppID'),
            'secret' => Config::get('app.wx_gzh_AppSecret'),
        ];
        $app = Factory::officialAccount($config);
        return $app->template_message->send([
            'touser' => $openId,
            'template_id' => 'MQNAyssWLuUmtnAeAX7EOSbULTYUgaLtd-hezWy0Oao',
            'url' => 'https://www.16huixuan.com/api/Wechat/index',
            'data' => $data,
        ]);
    }


    /*** 订单审核通知            订单审核通过/拒绝提示
     * @param $openId           微信openID
     * @param array $data       模板数据格式
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public static function orderAuditWeChatMsgSend($openId,array $data){
        $config = [
            'app_id' => Config::get('app.wx_gzh_AppID'),
            'secret' => Config::get('app.wx_gzh_AppSecret'),
        ];
        $app = Factory::officialAccount($config);
        return $app->template_message->send([
            'touser' => $openId,
            'template_id' => 'xaL0HXV6V0BPcXWCInPhNHEToKlhg5LVQ_3H0yvQeOE',
            'url' => 'https://www.16huixuan.com/api/Wechat/index',
            'data' => $data,
        ]);
    }

    /*** 订单审核通过 超时三天未进行评价  发送消息进行催评
     * @param $openId
     * @param $data
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public static function orderUrgeEstmateWechantMsgSend($openId,$data){
        $config = [
            'app_id' => Config::get('app.wx_gzh_AppID'),
            'secret' => Config::get('app.wx_gzh_AppSecret'),
        ];
        $app = Factory::officialAccount($config);
        return $app->template_message->send([
            'touser' => $openId,
            'template_id' => 'NJI2UAn6vAIL4Fb6bt-2iAIkXmMtXIBumBz_q8b3Ekk',
            'url' => 'https://www.16huixuan.com/api/Wechat/index',
            'data' => $data,
        ]);
    }

    /*** 返利提醒                订单到期解冻用户返利金  消息提醒
     * @param $openId           微信openID
     * @param array $data       模板数据格式
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public static function orderUnfreezeWeChatMsgSend($openId,array $data){
        $config = [
            'app_id' => Config::get('app.wx_gzh_AppID'),
            'secret' => Config::get('app.wx_gzh_AppSecret'),
        ];
        $app = Factory::officialAccount($config);
        return $app->template_message->send([
            'touser' => $openId,
            'template_id' => '-gFmdpedDQFS15Lps3JK2V4sTPtECnmcEclg3w14zes',
            'url' => 'https://www.16huixuan.com/api/Wechat/index',
            'data' => $data,
        ]);
    }

    /*** 申诉通知             商家发起申诉  微信消息推送 通知买家
     * @param $openId
     * @param array $data
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public static function orderComplainWeChatMsgSend($openId,array $data){
        $config = [
            'app_id' => Config::get('app.wx_gzh_AppID'),
            'secret' => Config::get('app.wx_gzh_AppSecret'),
        ];
        $app = Factory::officialAccount($config);
        return $app->template_message->send([
            'touser' => $openId,
            'template_id' => 'b2wjQC0mJt0PFL85Swyh5-4au5DcTbY_sR4SUoP3BE4',
            'url' => 'https://www.16huixuan.com/api/Wechat/index',
            'data' => $data,
        ]);
    }

    /*** 申诉结果通知       商家同意申诉     后台审核申诉结果通知
     * @param $openId
     * @param array $data
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public static function orderComplainTrueWeChatMsgSend($openId,array $data){
        $config = [
            'app_id' => Config::get('app.wx_gzh_AppID'),
            'secret' => Config::get('app.wx_gzh_AppSecret'),
        ];
        $app = Factory::officialAccount($config);
        return $app->template_message->send([
            'touser' => $openId,
            'template_id' => 'PMgr7xSFHmK2TvFarkblNf5Vv5nua1BZVL8r0QJVsM8',
            'url' => 'https://www.16huixuan.com/api/Wechat/index',
            'data' => $data,
        ]);
    }

    /*** 石榴过期通知
     * @param $openId
     * @param array $data
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public static function goldOverdueWeChantMsgSend($openId,array $data){
        $config = [
            'app_id' => Config::get('app.wx_gzh_AppID'),
            'secret' => Config::get('app.wx_gzh_AppSecret'),
        ];
        $app = Factory::officialAccount($config);
        return $app->template_message->send([
            'touser' => $openId,
            'template_id' => '55PX8Ak98-GhvblsfoYsNytqq9uoC-xMf-4KPIQ_vxo',
            'url' => 'https://www.16huixuan.com/api/Wechat/index',
            'data' => $data,
        ]);
    }

    /*** 试用活动中奖消息通知 -- 废除
     * @param $openId
     * @param array $data
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
//    public static function orderTrialWinnerWeChantMsgSend($openId,array $data){
//        $config = [
//            'app_id' => Config::get('app.wx_gzh_AppID'),
//            'secret' => Config::get('app.wx_gzh_AppSecret'),
//        ];
//        $app = Factory::officialAccount($config);
//        return $app->template_message->send([
//            'touser' => $openId,
//            'template_id' => '_w0Fr-f-Fd62DKLm87gh9YZvEQiivpvcgxbNXWBN_Qk',
//            'url' => 'https://www.16huixuan.com/api/Wechat/index',
//            'data' => $data,
//        ]);
//    }

    /*** 试用活动中奖消息通知  -- 当前试用
     * @param $openId
     * @param array $data
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public static function orderTrialWinnerWeChantMsgSend($openId,array $data){
        $config = [
            'app_id' => Config::get('app.wx_gzh_AppID'),
            'secret' => Config::get('app.wx_gzh_AppSecret'),
        ];
        $app = Factory::officialAccount($config);
        return $app->template_message->send([
            'touser' => $openId,
            'template_id' => 'b3bjuSjAYHt0ltKxiy0Ua2qNZreaNNFmiSyLRRVzEXo',
            'url' => 'https://www.16huixuan.com/api/Wechat/index',
            'data' => $data,
        ]);
    }


    /*** 预售订单  商家关闭  用户消息通知
     * @param $openId
     * @param array $data
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public static function orderNumericalSelectionWeChantMsgSend($openId,array $data){
        $config = [
            'app_id' => Config::get('app.wx_gzh_AppID'),
            'secret' => Config::get('app.wx_gzh_AppSecret'),
        ];
        $app = Factory::officialAccount($config);
        return $app->template_message->send([
            'touser' => $openId,
            'template_id' => 'luMsqsdxGQDMCqN7m4VTWimO3Q_p9DzF4cJF1Ylm8js',
            'url' => 'https://www.16huixuan.com/api/Wechat/index',
            'data' => $data,
        ]);
    }
}